<!--#include file="../../../core/common/Conn.asp" -->
<!--#include file="../../../core/common/Function.asp" -->
<!--#include file="../../../core/common/Limit.asp" -->
<%
	dim action
	action = request.QueryString("action")
	if action = "edit" then
		call edit
	end if
	call default
	
	dim CONTENT,UPDATETIME,SUBJECTID
	
	'加载内容
	sub default
		SUBJECTID = request.QueryString("subjectid")
		
		dim rs,sql
		sql = "select * from [ONE] where SUBJECTID = '"& SUBJECTID &"'"
		set rs = db.query(sql)
		if not rs.eof then
			CONTENT = rs("CONTENT")
			UPDATETIME = rs("UPDATETIME")
		else
			CONTENT = ""
			UPDATETIME = ""
		end if
		rs.close
		set rs = nothing
	end sub
	
	'编辑内容
	sub edit
		SUBJECTID = request.Form("SUBJECTID")
		CONTENT = request.Form("CONTENT")
		
		dim rs,sql
		sql = "select * from [ONE] where SUBJECTID = '"& SUBJECTID &"'"
		set rs = db.query(sql)
		if not rs.eof then
			rs("CONTENT") = CONTENT
			rs("UPDATETIME") = now
			rs.update
		else
			rs.addnew
			rs("SUBJECTID") = SUBJECTID
			rs("CONTENT") = CONTENT
			rs("UPDATETIME") = now
			rs.update
		end if
		rs.close
		set rs = nothing
		
		response.Redirect("index.asp?subjectid=" & SUBJECTID)
	end sub
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CMSLite for ASP</title>
<link href="../../resource/css/reset.css" rel="stylesheet" type="text/css" />
<link href="../../resource/css/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resource/js/jquery-1.6.2.min.js"></script>
<script type="text/javascript" src="../../resource/js/common.js"></script>

<link href="../../resource/js/kindeditor/themes/default/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../resource/js/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="../../resource/js/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript">
//初始化编辑器
var editor;
KindEditor.ready(function(K) {
	editor = K.create('#editor',{
		uploadJson : '../../resource/js/kindeditor/asp/upload_json.asp',
		fileManagerJson : '../../resource/js/kindeditor/asp/file_manager_json.asp',
		allowFileManager : true
	});
});
</script>
</head>

<body id="body">
	<div class="title_bar">
	内容编辑 - <%=Get_Subject_Name(SUBJECTID)%>
	</div>
	<form action="?action=edit" method="post">
	<p>
		<label>内容</label>
		<textarea name="CONTENT" id="editor" tabindex="1" style="width:100%;height:300px;margin:0 auto;">
		<%=CONTENT%>
		</textarea>
	</p>
	<p>
	上次修改时间：<%=UPDATETIME%>
	</p>
	<p>
		<input type="submit" class="button_1" value="修改" />
		<input type="button" class="button_1" value="返回" onclick="location.href='/admin/subject/subject.asp';" />
		<input type="hidden" name="SUBJECTID" value="<%=SUBJECTID%>" />
	</p>
	</form>
</body>
</html>
